Skip to content

test(core,docs): M3.5 — sandbox attack-vector test suite + security-model.md#18

Merged
oratis merged 1 commit into
mainfrom
test/m3.5-sandbox-attacks
May 28, 2026
Merged

test(core,docs): M3.5 — sandbox attack-vector test suite + security-model.md#18
oratis merged 1 commit into
mainfrom
test/m3.5-sandbox-attacks

Conversation

@oratis

@oratis oratis commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the M3.5: 75% — missing attack vectors line item from the morning report. 17 new tests, profile hardened to actually run real commands, security model documented.

  • packages/core/src/sandbox/attacks.test.ts — 17 tests in 5 buckets (SBPL hostile-input escaping, bwrap arg safety, excluded-command spoofing, macOS e2e under sandbox-exec, Linux e2e under bwrap). Platform-conditional tests use it.runIf().
  • packages/core/src/sandbox/profile.ts — added (literal "/"), (literal "/private"), (subpath "/private/var/folders"), and (allow process-info*) so generated profiles can actually exec /bin/sh -c ... instead of dying with SIGABRT in dyld. The previous tests only validated profile string content, never that sandbox-exec could parse + run it.
  • docs/security-model.md (NEW) — threat model, defence layers, hostile-input handling, attack-vector test inventory, explicit list of known gaps with milestone tracking (DNS exfil, OS-wrap of plugin process, pipeline analysis, domain whitelist).

Test plan

  • pnpm -F @deepcode/core test src/sandbox/ — 34 passed / 3 skipped (was 13 pass; +17 attack tests, +2 e2e on macOS runner, 2 skipped Linux e2e)
  • pnpm -r test — 308 + 41 = 349 passing
  • pnpm -F @deepcode/core build — clean

Notable

  • One test documents a known weakness: pipeline-after-excluded-command bypasses sandbox. Pinned by a test so future hardening doesn't silently change semantics. M5.2 tracks fixing.
  • The profile hardening ((literal "/") etc.) is required for ANY sandboxed exec to work on modern macOS — without it /bin/sh itself can't start under (deny default). Previously the smoke test only checked profile-text contents, not runtime behavior.

🤖 Generated with Claude Code

…odel.md

Closes the "M3.5: 75% — missing attack vectors" gap from the morning report.

  · packages/core/src/sandbox/attacks.test.ts (17 tests)
    - 6 SBPL hostile-input tests: paren/quote/backslash escaping,
      deny-after-allow ordering, no implicit network when allowedDomains=[],
      no implicit writes to /usr|/System|/Library.
    - 3 bwrap arg safety tests: no --share-net, only cwd is bare --bind,
      pid/ipc/uts always unshared.
    - 4 excluded-command spoofing tests: prefix-only doesn't bypass; pipeline
      after-excluded DOES bypass (documented as known M5.2-tracked behavior).
    - 2 sandbox-exec e2e tests on macOS: block /usr/local/bin write; profile
      parses without syntax error (smoke).
    - 2 bwrap e2e tests on Linux: block outside-cwd write; DNS unshared when
      allowedDomains=[].

  · packages/core/src/sandbox/profile.ts hardened so e2e tests pass:
    - Add `(allow file-read* (literal "/"))` and related (literal "/private")
      entries so shell getcwd / parent stat succeed under deny-default.
    - Add `(allow file-read* (subpath "/private/var/folders"))` for dyld
      closure cache (without this, /bin/sh exited with SIGABRT before any
      command could run).
    - Add `(allow process-info*)`.

  · docs/security-model.md (NEW, ~180 lines):
    threat model, defence layers (trust → modes → permissions → sandbox →
    plugin subprocess → credentials), hostile-input handling, attack-vector
    test inventory, explicit list of known gaps (DNS exfil, OS-wrap of plugin
    process, pipeline analysis, domain whitelist) with milestone tracking.

Tests: 308/10 pass/skip in core (was 293), 41 in cli unchanged. Total 349 passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oratis oratis merged commit 03293ac into main May 28, 2026
1 of 2 checks passed
@oratis oratis deleted the test/m3.5-sandbox-attacks branch May 28, 2026 05:18
oratis added a commit that referenced this pull request May 28, 2026
This session ("继续推进" from v2) added 5 PRs on top of #1-#16:
  · #17 M3c-rest tools (TodoWrite + WebFetch + WebSearch)
  · #18 M3.5 attack tests + security-model.md
  · #19 M8 headless mode (-p / --print)
  · #20 M5.2 plugin live wire-up
  · #21 system-reminder injector

Test count: 313 → 387 (+74).
Scope completion estimate: 65-70% → 72-78%.

Major remaining items: M6 Mac Electron (still 0%), M7 file panel (depends
on M6), and the M3c-rest/M8/M5.2 leftovers itemized in the body.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant